home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
001-100
/
001-025
/
012
/
iconexec
/
setwindow.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-17
|
2KB
|
69 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* SetWindow - Set the ToolWindow for an ICON */
/* (c) Copyright 1986 John A. Toebes, VIII All rights reserved */
/* 120-H Northington Place, Cary NC 27511 (919) 469-4210 */
/* This program may be used and modified for any purpose so long as */
/* this copyright notice remains with the code and the program is not */
/* sold and no charge is made for its use. */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* To use:
1) Compile and link as any other program
2) Issue command to modify whatever Icon you wish to
SetWindow <icon> <window specifications>
*/
#include <stdio.h>
#include <exec/types.h>
#include <workbench/workbench.h>
#include <workbench/icon.h>
#include <workbench/startup.h>
int IconBase;
extern struct WBStartup *WBenchMsg;
main(argc,argv)
int argc;
char *argv[];
{
struct DiskObject *diskobj, *GetDiskObject();
char *savewindow;
/* make sure we ran from CLI */
if (argc == 0) exit(1);
/* make sure we have enough parms */
if (argc != 2 && argc != 3)
{
printf("Usage: %s <icon> [<windowspec>]\n", argv[0]);
exit(2);
}
if ( (IconBase = OpenLibrary( ICONNAME, 1)) == NULL)
exit(2);
/* get the icon from disk */
if ( (diskobj = GetDiskObject(argv[1])) == NULL)
{
printf("Cannot read icon for %s\n", argv[1]);
CloseLibrary( IconBase );
exit(3);
}
/* remember what the previous window was */
savewindow = diskobj->do_ToolWindow;
/* set it to what was requested */
diskobj->do_ToolWindow = (argc > 2) ? argv[2] : NULL;
/* write the corrected ICON to disk */
if (!PutDiskObject( argv[1], diskobj))
printf("Cannot write new icon - code %d\n", IoErr() );
/* restore the oldwindow and free the object */
diskobj->do_ToolWindow = savewindow;
FreeDiskObject( diskobj );
CloseLibrary( IconBase );
}